package com.xwj.airag.trigger.http;

import org.springframework.core.io.ClassPathResource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.io.IOException;
import java.nio.file.Files;

@Controller
public class IndexController {
    @GetMapping({"/", "/index"})
    public ResponseEntity<byte[]> index() throws IOException {
        ClassPathResource resource = new ClassPathResource("templates/index.html");
        byte[] content = Files.readAllBytes(resource.getFile().toPath());
        return ResponseEntity.ok().header("Content-Type", "text/html; charset=UTF-8").body(content);
    }


    @GetMapping({ "/upload"})
    public ResponseEntity<byte[]> update() throws IOException {
        ClassPathResource resource = new ClassPathResource("templates/upload.html");
        byte[] content = Files.readAllBytes(resource.getFile().toPath());
        return ResponseEntity.ok().header("Content-Type", "text/html; charset=UTF-8").body(content);
    }
}
